﻿<UserControl   x:Class="Ops.Mpc.ExampleApplication.SimpleBindings.SimpleBindingsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:presenters="clr-namespace:Ops.Mpc.Presenters;assembly=Ops.Mpc"
    xmlns:controllers="clr-namespace:Ops.Mpc.Controllers;assembly=Ops.Mpc"   
    xmlns:states="clr-namespace:Ops.Mpc.States;assembly=Ops.Mpc"   
    xmlns:simplemodels="clr-namespace:Ops.Mpc.ExampleApplication.SimpleBindings.Models"  
    xmlns:simplestateactions="clr-namespace:Ops.Mpc.ExampleApplication.SimpleBindings.Actions"
    xmlns:actions="clr-namespace:Ops.Mpc.ExampleApplication.Actions"           
 
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <presenters:Presenter x:Name="Presenter1" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
        <controllers:Controller>
            <controllers:Controller.Models>
                <simplemodels:SimpleModel ItemName="SimpleModel"/>
            </controllers:Controller.Models>
            <controllers:Controller.States>
                <states:State ItemName="DefaultState" AutoRun="True">
                    <states:StateTemplate FocusControlName="FirstNameTextBox">
                        <Grid>
                           <Grid HorizontalAlignment="Center" VerticalAlignment="Center" >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto" />
                                    <ColumnDefinition Width="5"/>
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="auto" />
                                    <RowDefinition Height="auto" />
                                    <RowDefinition Height="auto" />
                                    <RowDefinition Height="auto" />
                                </Grid.RowDefinitions>
                                <TextBlock Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" Text="Person Id" />
                                <TextBlock Grid.Column="2" Grid.Row="0" VerticalAlignment="Center" Text="{Binding Models[SimpleModel].PersonId, Mode=TwoWay}" Margin="2"/>
                                <TextBlock Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" Text="First Name" />
                                <TextBox x:Name="FirstNameTextBox"  Grid.Column="2" Grid.Row="1" VerticalAlignment="Center" Text="{Binding Models[SimpleModel].FirstName, Mode=TwoWay}" Margin="2"/>
                                <TextBlock Grid.Column="0" Grid.Row="2" VerticalAlignment="Center"  Text="Last Name" />
                                <TextBox Grid.Column="2" Grid.Row="2" VerticalAlignment="Center"  Text="{Binding Models[SimpleModel].LastName, Mode=TwoWay}" Margin="2"/>
                                <Button Grid.Column="2" Grid.Row="3" Content="Create Person" Command="{Binding StateActions[CreatePersonStateAction]}" Margin="5" />
                             </Grid>
                         </Grid>
                    </states:StateTemplate>
                    <states:State.StateActions>
                        <actions:SetMainMessageStateAction ItemName="SetMainMessageStateAction" MessageId="SimpleBindingsMessage"  />
                        <simplestateactions:CreatePersonStateAction ItemName="CreatePersonStateAction" ValidationModelItemName="SimpleModel" BusyIndicatorModelItemName="BusyIndicatorModel" />
                    </states:State.StateActions>
                </states:State>
            </controllers:Controller.States>
        </controllers:Controller>
    </presenters:Presenter>
</UserControl>
